<div id="update-challenge" class="modal fade" tabindex="-1">
    <div class="modal-dialog">
        <div class="modal-content">
            <div class="modal-header">
                <button type="button" class="close" data-dismiss="modal">&times;</button>
                <h3 class="chal-title text-center"></h3>
            </div>
            <div class="modal-body">
                <form method="POST" action="{{ request.script_root }}/admin/chal/update">
                    <input name='nonce' type='hidden' value="{{ nonce }}">

                    <div class="form-group">
                        <label for="name">Name
                            <i class="fa fa-question-circle gray-text" data-toggle="tooltip" data-placement="right" title="The name of your challenge"></i>
                        </label>
                        <input type="text" class="form-control chal-name" name="name" placeholder="Enter challenge name">
                    </div>
                    <div class="form-group">
                        <label for="category">Category
                            <i class="fa fa-question-circle gray-text" data-toggle="tooltip" data-placement="right" title="The category of your challenge"></i>
                        </label>
                        <input type="text" class="form-control chal-category" name="category" placeholder="Enter challenge category">
                    </div>

                    <ul class="nav nav-tabs" role="tablist" id="desc-edit">
                        <li role="presentation" class="active"><a href="#desc-write" id="desc-write-link" aria-controls="home" role="tab" data-toggle="tab">Write</a></li>
                        <li role="presentation"><a href="#desc-preview" aria-controls="home" role="tab" data-toggle="tab">Preview</a></li>
                    </ul>
                    <div class="tab-content">
                        <div role="tabpanel" class="tab-pane active" id="desc-write">
                            <div class="form-group">
                                <label for="message-text" class="control-label">Message:
                                    <i class="fa fa-question-circle gray-text" data-toggle="tooltip" data-placement="right" title="Use this to give a brief introduction to your challenge. The description supports HTML and Markdown."></i>
                                </label>
                                <textarea id="desc-editor" class="form-control chal-desc" name="desc" rows="10"></textarea>
                            </div>
                        </div>
                        <div role="tabpanel" class="tab-pane content" id="desc-preview" style="height:214px; overflow-y: scroll;">
                        </div>
                    </div>

                    <!-- ADDED BY ME: -->
                    <div class="tab-content">
                        <div role="tabpanel" class="tab-pane active" id="solidity-write">
                            <div class="form-group">
                                <label for="solidity" class="control-label">Solidity Source:
                                    <i class="fa fa-question-circle gray-text" data-toggle="tooltip" data-placement="right" title="Paste the solidity source for the contract here."></i>
                                </label>
                                <textarea id="solidity-editor" class="form-control" name="solidity" rows="10"></textarea>
                            </div>
                        </div>
                    </div>

                    <div class="tab-content">
                        <div role="tabpanel" class="tab-pane active" id="test-func-write">
                            <div class="form-group">
                                <label for="test_func" class="control-label">Test Expression (Python):
                                    <i class="fa fa-question-circle gray-text"
                                    data-toggle="tooltip" data-placement="right" title="Paste a one line expression to test the contract here. You have access to your contract as a web3 contract called 'contract'"></i>
                                </label>
                                <input id="test-func-editor" class="form-control" name="test_func" placeholder="contract.call().myFunction() == 4 and contract.call().getUserBalance < 0" rows="10"></input>
                            </div>
                        </div>
                    </div>
                    <div class="tab-content">
                        <div role="tabpanel" class="tab-pane active" id="args-write">
                            <div class="form-group">
                                <label for="args" class="control-label">Starting Arguments (Python List):
                                    <i class="fa fa-question-circle gray-text"
                                    data-toggle="tooltip" data-placement="right" title="Paste a python list that contains the arguments to the contract. Default:[]"></i>
                                </label>
                                <input id="args-editor" class="form-control" name="args" rows="10" required></input>
                            </div>
                        </div>
                    </div>

		    <div class="form-group">
			<label for="starting-ether">Starting Ether
			    <i class="fa fa-question-circle gray-text" data-toggle="tooltip" data-placement="right" title="This is how much ether the smart contract should be preloaded with. The constructor must be payable."></i>
			</label>
			<input id="starting-ether-input" type="number" class="form-control" name="starting-ether" placeholder="Enter starting ether" required>
		    </div>
                    <!-- END ADDED BY ME -->

                    <div class="form-group">
                        <label for="value">Value
                            <i class="fa fa-question-circle gray-text" data-toggle="tooltip" data-placement="right" title="This is how many points teams will receive once they solve this challenge."></i>
                        </label>
                        <input type="number" class="form-control chal-value" name="value" placeholder="Enter value" required>
                    </div>

                    <div class="checkbox">
                        <label>
                            <input class="chal-attempts-checkbox" id="limit_max_attempts" name="limit_max_attempts" type="checkbox">
                            Limit challenge attempts
                        </label>
                    </div>

                    <div class="form-group" id="chal-attempts-group" style="display:none;">
                        <label for="value">Max Attempts</label>
                        <input type="number" class="form-control chal-attempts" id="chal-attempts-input" name="max_attempts" placeholder="Enter value">
                    </div>
                    <input class="chal-id" type='hidden' name='id' placeholder='ID'>

                    <div class="checkbox">
                        <label>
                            <input class="chal-hidden" name="hidden" type="checkbox">
                            Hidden
                        </label>
                    </div>

                    <div class="form-group">
                        <a href="#" data-toggle="modal" data-target="#update-tags" class="btn btn-primary">Tags</a>
                        <a href="#" data-toggle="modal" data-target="#update-files" class="btn btn-primary">Files</a>
                        <a href="#" data-toggle="modal" data-target="#update-hints" class="btn btn-primary">Hints</a>
                        <a href="#" data-toggle="modal" data-target="#update-keys" class="btn btn-primary">Keys</a>
                        <a href="#" data-toggle="modal" data-target="#delete-chal" class="btn btn-danger">Delete</a>
                    </div>
                    <input type="hidden" value="{{ nonce }}" name="nonce" id="nonce">
                    <div style="text-align:center">
                        <button class="btn btn-theme btn-outlined update-challenge-submit" type="submit">Update</button>
                    </div>
                </form>
            </div>
        </div>
    </div>
</div>

<div id="update-tags" class="modal fade" tabindex="-1">
    <div class="modal-dialog">
        <div class="modal-content">
            <div class="modal-header text-center">
                <button type="button" class="close" data-dismiss="modal">&times;</button>
                <h3>Tags</h3>
            </div>
            <div class="modal-body">
                <div class="form-group">
                    <label for="tag-insert">Value</label>
                    <input max-length="80" type="text" class="form-control tag-insert" name="tag-insert" placeholder="Type tag and press Enter">
                </div>
                <input name='nonce' type='hidden' value="{{ nonce }}">
                <input id="tags-chal" name='chal' type='hidden'>

                <div id="current-tags">

                </div>
                <br/>
                <div id="chal-tags">
                </div>
                <div class="row" style="text-align:center;margin-top:20px">
                    <input type="hidden" value="{{ nonce }}" name="nonce" id="nonce">
                    <button class="btn btn-theme btn-outlined" id="submit-tags">Update</button>
                </div>
            </div>
        </div>
    </div>
</div>

<div id="update-files" class="modal fade" tabindex="-1">
    <div class="modal-dialog">
        <div class="modal-content">
            <div class="modal-header text-center">
                <button type="button" class="close" data-dismiss="modal">&times;</button>
                <h3>Files</h3>
            </div>
            <div class="modal-body">
                <form method="POST" action="{{ request.script_root }}/admin/files/" enctype="multipart/form-data">
                    <input name='nonce' type='hidden' value="{{ nonce }}">
                    <input id="files-chal" name='chal' type='hidden'>
                    <input name='method' type='hidden' value='upload'>

                    <div id="current-files"></div>
                    <input type="hidden" name="method" value="upload">
                    <input type="file" name="files[]" multiple="multiple">
                    <sub class="help-block">Attach multiple files using Control+Click or Cmd+Click.</sub>
                    <div class="row" style="text-align:center;margin-top:20px">
                        <input type="hidden" value="{{ nonce }}" name="nonce" id="nonce">
                        <button class="btn btn-theme btn-outlined" id="submit-files">Update</button>
                    </div>
                </form>
            </div>
        </div>
    </div>
</div>

<div id="update-hints" class="modal fade" tabindex="-1">
    <div class="modal-dialog">
        <div class="modal-content">
            <div class="modal-header text-center">
                <button type="button" class="close" data-dismiss="modal">&times;</button>
                <h3>Hints</h3>
            </div>
            <div class="modal-body">
                <div class="row" style="text-align:center">
                    <a href="#" id="create-hint" class="btn btn-primary" style="margin-bottom:15px;">New Hint</a>
                </div>
                <div class='current-hints'>
                    <table id="hintsboard" class="table table-striped">
                        <thead>
                            <tr>
                                <td class="text-center"><b>Hint</b></td>
                                <td class="text-center"><b>Cost</b></td>
                                <td class="text-center"><b>Settings</b></td>
                            </tr>
                        </thead>
                        <tbody class="text-center">
                        </tbody>
                    </table>
                </div>
            </div>
        </div>
    </div>
</div>

<div id="update-keys" class="modal fade" tabindex="-1">
    <div class="modal-dialog">
        <div class="modal-content">
            <div class="modal-header text-center">
                <button type="button" class="close" data-dismiss="modal">&times;</button>
                <h3>Keys</h3>
            </div>
            <div class="modal-body">
                <form method="POST" action="{{ request.script_root }}/admin/keys" style="text-align:center">
                    <a href="#" id="create-key" class="btn btn-primary" style="margin-bottom:15px;">New Key</a>
                    <input name='nonce' type='hidden' value="{{ nonce }}">
                    <input id="keys-chal" name='chal' type='hidden'>
                    <div id="current-keys" class="row"></div>
                </form>
            </div>
        </div>
    </div>
</div>

<div id="delete-chal" class="modal fade" tabindex="-1">
    <div class="modal-dialog">
        <div class="modal-content">
            <div class="modal-header text-center">
                <button type="button" class="close" data-dismiss="modal">&times;</button>
                <h3>Delete Challenge</h3>
            </div>
            <div class="modal-body">
                <form method="POST" action="{{ request.script_root }}/admin/chal/delete">
                    <input type="hidden" name="nonce" value="{{ nonce }}">
                    <input type="hidden" name="id" class="chal-id">
                    <div class="small-6 small-centered text-center columns">
                        <p>Are you sure you want to delete this challenge?</p>
                        <p>Solves, wrong keys, files, tags will all be deleted.</p>
                        <a onclick="$('#delete-chal').modal('hide')" class="btn btn-primary">No</a>
                        <button class="btn btn-danger" id="delete-user" type="submit">Delete</button>
                    </div>
                </form>
            </div>
        </div>
    </div>
</div>

<div id="create-keys" class="modal fade" tabindex="-1">
    <div class="modal-dialog">
        <div class="modal-content">
            <input type="hidden" class="chal-id" name="chal-id">
            <div class="modal-header text-center">
                <button type="button" class="close" data-dismiss="modal">&times;</button>
                <h3>Create Key</h3>
            </div>
            <div class="modal-body">
                <div class="create-keys-select-div">
                    <label for="create-keys-select" class="control-label">Choose Key Type</label>
                    <select class="form-control" id="create-keys-select">
                    </select>
                </div>
                <br>
                <div id="create-keys-entry-div">
                </div>
                <br>
                <div style="text-align:center;display:none;" id="create-keys-button-div">
                   <button id="create-keys-submit" class="btn btn-theme btn-outlined">Create Key</button>
                </div>
            </div>
        </div>
    </div>
</div>

<div id="edit-keys" class="modal fade" tabindex="-1">
</div>

<div id="hint-modal" class="modal fade" tabindex="-1">
    <div class="modal-dialog">
        <div class="modal-content">
            <div class="modal-header text-center">
                <button type="button" class="close" data-dismiss="modal">&times;</button>
                <h3 id="hint-modal-title"></h3>
            </div>
            <div class="modal-body">
                <form id="hint-modal-submit" method='POST'>
                    <input type="hidden" class="chal-id" name="chal">
                    <div class="form-group">
                        <textarea id="hint-modal-hint" type="text" class="form-control" name="hint" placeholder="Hint"></textarea>
                    </div>
                    <div class="form-group">
                        <input id="hint-modal-cost" type="number" class="form-control" name="cost" placeholder="Cost">
                    </div>
                    <div class="row" style="text-align:center;margin-top:20px">
                        <input type="hidden" value="{{ nonce }}" name="nonce" id="nonce">
                        <button class="btn btn-theme btn-outlined" id="hint-modal-button">Add Hint</button>
                    </div>
                </form>
            </div>
        </div>
    </div>
</div>
